@import './theme/font';
@import './theme/default';

@mixin gray-color {
  @include theme-color(color, stroke, 4);
}

@mixin blue-bgcolor {
  @include theme-color(background-color, primary, 8);
}

@mixin gray-bgcolor {
  @include theme-color(background-color, stroke, 8);
}

@mixin white-bgcolor {
  @include theme-color(background-color, stroke, 9);
}

@mixin border-with-radius {
  border-width: 1px;
  border-style: solid;
  border-radius: 2px;
}

@mixin panel-common {
  @include white-bgcolor;
  @include theme-shadow(layer);
  border-radius: 2px;
  z-index: 1;
}

@mixin center-div {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin panel-footer-common {
  @include theme-color(border-top-color, stroke, 6);
  border-top-width: 1px;
  border-top-style: solid;
  box-sizing: border-box;
  display: flex;
  padding: 9px 12px 10px;
}

.zent-datepicker {
  box-sizing: border-box;
  display: inline-block;
  position: relative;

  $p: &;

  &-seperator {
    margin: 0 8px;
  }

  .zenticon {
    @include gray-color;
    font-size: 18px;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
  }

  .zenticon-calendar-o,
  .zenticon-clock-o {
    display: block;
  }

  .zenticon-close-circle {
    display: none;
  }

  &-can-clear {
    cursor: pointer;

    &:hover {
      .zenticon-close-circle {
        display: block;
      }

      .zenticon-calendar-o,
      .zenticon-clock-o {
        display: none;
      }
    }
  }

  &-popup {
    z-index: 2000;
  }

  &-trigger {
    @include theme-color(border-color, stroke, 5);
    @include border-with-radius;
    @include theme-color(background-color, stroke, 9);

    display: flex;
    align-items: center;
    height: 32px;
    width: 360px;
    padding: 0 10px;
    box-sizing: border-box;

    &-input {
      @include theme-color(color, stroke, 1);
      border: 0;
      min-width: 60px;
      padding: 0;
      outline: none;
      font-size: $font-size-normal;
    }

    &-empty-input {
      @include theme-color(color, stroke, 4);
    }

    &-seperator {
      @include theme-color(color, stroke, 4);

      margin: 0 8px;
    }

    &-focus {
      @include theme-color(border-color, primary, 4);
    }

    &:not(#{$p}-disabled):hover {
      cursor: pointer;
      @include theme-color(border-color, primary, 4);
    }
  }

  &-disabled {
    @include theme-color(border-color, stroke, 6);
    @include theme-color(background-color, stroke, 8);
    cursor: not-allowed;

    .zent-datepicker-trigger {
      &-input,
      &-empty-input,
      &-seperator {
        @include theme-color(color, stroke, 4);
      }
    }
  }

  &-panel {
    @include panel-common;
    width: 280px;
    cursor: pointer;

    &_lunar {
      width: 330px;
    }

    &-header {
      @include font-large;
      display: flex;
      justify-content: space-between;
      padding: 16px;
      align-items: center;

      &-btns {
        display: flex;
        width: 36px;
        justify-content: space-between;
      }

      &-arrow {
        font-size: 20px;
        border-radius: 2px;
        &:hover {
          @include theme-color(background-color, stroke, 5, 0.3);
        }
        &:active {
          @include theme-color(background-color, stroke, 5, 0.6);
        }
      }

      &-title {
        display: flex;
        font-weight: $font-weight-medium;

        &_clickable {
          &:hover {
            @include theme-color(color, primary, 5);
            cursor: pointer;
          }

          &:nth-child(2) {
            margin-left: 4px;
          }
        }
      }
    }

    &-sub_header {
      @include theme-color(color, stroke, 3);
      display: flex;
      justify-content: space-between;
      padding: 0 24px;
      cursor: default;
    }

    &-body-cells {
      padding: 12px;

      &_row {
        @include center-div;
      }

      &_item {
        text-align: center;
        padding: 0 6px;
        margin: 4px 0;
        cursor: pointer;
      }

      .zent-datepicker-cell-inner {
        @include center-div;
        width: 24px;
        height: 24px;
        box-sizing: border-box;
      }

      .zent-datepicker-lunar-cell {
        display: block;
        width: 32px;
        height: 38px;

        &_text {
          font-size: $font-size-small;
        }
      }

      &_current {
        .zent-datepicker-cell-inner {
          @include border-with-radius;
          @include theme-color(color, primary, 4);
          @include theme-color(border-color, primary, 4);
        }
      }

      &_in_hover_range {
        @include gray-bgcolor;
      }

      &_selected {
        @include white-bgcolor;

        .zent-datepicker-cell-inner {
          @include blue-bgcolor;
          border-radius: 2px;
        }
      }

      &_available:hover {
        .zent-datepicker-cell-inner:hover {
          @include gray-bgcolor;
          border-radius: 2px;
        }
      }

      &_in_range {
        @include blue-bgcolor;
        &:hover {
          .zent-datepicker-cell-inner:hover {
            @include blue-bgcolor;
          }
        }
      }

      &_over,
      &_disabled {
        @include white-bgcolor;

        .zent-datepicker-cell-inner {
          @include theme-color(color, stroke, 4);
        }
      }

      &_disabled:hover {
        cursor: not-allowed;
      }

      &_disabled.zent-datepicker-panel-body-cells_current {
        .zent-datepicker-cell-inner {
          @include gray-color;
          @include border-with-radius;
          @include theme-color(border-color, stroke, 4);
        }
      }

      &_selected.zent-datepicker-panel-body-cells_disabled {
        .zent-datepicker-cell-inner {
          @include border-with-radius;
          @include theme-color(background-color, stroke, 4);
          @include theme-color(color, stroke, 9);
        }
      }

      &_in_hover_range.zent-datepicker-panel-body-cells_over {
        @include gray-bgcolor;
      }

      &_in_range.zent-datepicker-panel-body-cells_over {
        @include blue-bgcolor;
      }

      &_selected.zent-datepicker-panel-body-cells_over {
        @include white-bgcolor;
      }
    }

    &-footer {
      @include panel-footer-common;
      justify-content: space-between;
      align-items: center;
      flex-flow: row-reverse;

      &-input {
        width: 94px;
      }

      &-btn {
        margin-left: 12px;
      }

      &-current.zent-btn {
        margin-left: 0;
      }

      &-current.zent-btn {
        margin-left: 0;
      }

      &-current_disabled {
        @include gray-color;
      }
    }

    .zenticon {
      @include theme-color(color, stroke, 3);
    }
  }

  &-time-panel {
    &-body {
      display: flex;

      &_scroll {
        @include theme-color(border-right-color, stroke, 5);
        border-right-width: 1px;
        border-right-style: solid;
        flex: 1;
        width: 92px;
        height: 288px;
        box-sizing: border-box;
        overflow-y: scroll;
      }

      &_scroll:first-child {
        border-top-left-radius: 2px;
        border-bottom-left-radius: 2px;
      }

      &_scroll:last-child {
        border-top-right-radius: 2px;
        border-bottom-right-radius: 2px;
        border: 0;
      }

      &_scroll::after {
        content: '';
        display: block;
        height: 256px;
      }

      &-unit {
        @include center-div;
        height: 32px;
        cursor: pointer;

        &_selected {
          @include blue-bgcolor;
          font-weight: $font-weight-medium;
        }

        &_disabled {
          @include gray-color;
        }

        &_disabled:hover {
          cursor: not-allowed;
        }

        &_available:hover {
          @include gray-bgcolor;
        }
      }
    }
  }

  &-combined-panel {
    @include panel-common;
    display: flex;
    flex-direction: column;

    &-body {
      display: flex;

      &-item {
        flex: 1;

        &_left12 {
          margin-left: -12px;
        }
      }

      &-seperator {
        @include theme-color(border-left-color, stroke, 5);
        @include theme-color(border-right-color, stroke, 5);

        border-right-width: 1px;
        border-right-style: solid;
        border-left-width: 1px;
        border-left-style: solid;
        width: 24px;
        height: 288px;
      }
    }

    &-footer {
      @include panel-footer-common;

      &-item,
      &-seperator {
        line-height: 32px;
        margin: 0 4px;
      }

      &-seperator,
      &-null {
        @include theme-color(color, stroke, 3);
      }

      &-confirm {
        position: absolute;
        right: 16px;
      }
    }
  }

  &-ym-panel-body {
    .zent-datepicker-panel-body-cells {
      padding: 12px 24px;

      .zent-datepicker-cell-inner {
        @include center-div;
        width: 64px;
        height: 32px;
        margin: 8px 0;
      }
    }
  }

  &-quarter-panel-body {
    .zent-datepicker-panel-body-cells {
      padding: 12px 20px;

      &_item {
        margin: 12px 10px;

        .zent-datepicker-cell-inner {
          @include center-div;
          width: 92px;
          height: 36px;
        }
      }
    }
  }
}
